package com.trestristesmicos.anahuac;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.TextView;


public class ProgramasActivity  extends Activity {
        

        
        /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.programas);
        
        
        
        Typeface font1 = Typeface.createFromAsset(getAssets(), "fonts/ElektraLight.otf");
       
        TextView customText0 = (TextView)findViewById(R.id.TV_descripcionlicenciatura);
        
        customText0.setTypeface(font1);
       
        
        ImageButton bt1 = (ImageButton) findViewById(R.id.IB_programa1);       
        bt1.setOnClickListener(new OnClickListener() {

                    
                        public void onClick(View arg0) {
                                // TODO Auto-generated method stub
                                animatedStartActivity(1);
                        }               
        });      
        
        ImageButton bt3 = (ImageButton) findViewById(R.id.IB_programa2);       
        bt3.setOnClickListener(new OnClickListener() {

                        public void onClick(View arg0) {
                                // TODO Auto-generated method stub
                                animatedStartActivity(2);
                        }               
        });  
        
        ImageButton bt5 = (ImageButton) findViewById(R.id.IB_programa3);       
        bt5.setOnClickListener(new OnClickListener() {

                       
                        public void onClick(View arg0) {
                                // TODO Auto-generated method stub
                                animatedStartActivity(3);
                        }               
        });  
        
        ImageButton bt19 = (ImageButton) findViewById(R.id.IB_programa4);       
        bt19.setOnClickListener(new OnClickListener() {

                        
                        public void onClick(View arg0) {
                                // TODO Auto-generated method stub
                                animatedStartActivity(4);
                        }               
        });  
        
       
        
        
    }    
    
  
    
    private void animatedStartActivity(int position) {
		// we only animateOut this activity here.
		// The new activity will animateIn from its onResume() - be sure to implement it.
		
    	final Intent intent;
    	
    	switch (position) {
    	
    	case 1:
    		intent = new Intent(getApplicationContext(), Programa1.class);
			// disable default animation for new intent
			intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
			
			ActivitySwitcher.fadeOut(findViewById(R.id.container), getWindowManager(), new ActivitySwitcher.AnimationFinishedListener() {
			
				public void onAnimationFinished() {
					startActivity(intent);
				}
			});
    		break;
    	
    	case 2:
    		intent = new Intent(getApplicationContext(), Programa2.class);
			// disable default animation for new intent
			intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
			
			ActivitySwitcher.fadeOut(findViewById(R.id.container), getWindowManager(), new ActivitySwitcher.AnimationFinishedListener() {
				
				public void onAnimationFinished() {
					startActivity(intent);
				}
			});
    		break;
    	case 3:
    		intent = new Intent(getApplicationContext(), Programa3.class);
			// disable default animation for new intent
			intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
			
			ActivitySwitcher.fadeOut(findViewById(R.id.container), getWindowManager(), new ActivitySwitcher.AnimationFinishedListener() {
				
				public void onAnimationFinished() {
					startActivity(intent);
				}
			});
    		break;
		case 4:
			intent = new Intent(getApplicationContext(), Programa4.class);
			// disable default animation for new intent
			intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
			
			ActivitySwitcher.fadeOut(findViewById(R.id.container), getWindowManager(), new ActivitySwitcher.AnimationFinishedListener() {
				
				public void onAnimationFinished() {
					startActivity(intent);
				}
			});
						
			break;

    	}
   	}     
    
  
   
    
      
    
    @Override
        protected void onResume() {
                // animateIn this activity
                ActivitySwitcher.fadeIn(findViewById(R.id.container), getWindowManager());
                super.onResume();
        }
   
    @Override
        public void finish() {
                // we need to override this to performe the animtationOut on each
                // finish.
                ActivitySwitcher.fadeOut(findViewById(R.id.container), getWindowManager(), new ActivitySwitcher.AnimationFinishedListener() {
                       
                        public void onAnimationFinished() {
                                ProgramasActivity.super.finish();
                                // disable default animation
                                overridePendingTransition(0, 0);
                        }
                });
        }
    
   
  
}
